package io.gitee.caoxiaoyu97.log4j.defender.condition;

import com.cxy.common.config.ConfigUtils;
import io.gitee.caoxiaoyu97.log4j.defender.constants.DefenderConstants;
import org.apache.commons.lang3.StringUtils;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;

public class StringKeyDefenderEnableCondition implements Condition {
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
        try {
            String stringKeys = ConfigUtils.get(DefenderConstants.LOG_DEFENDER_T3EVENT_STRING_KEYS, "");
            return StringUtils.isNotEmpty(stringKeys);
        } catch (Exception e) {
            return false;
        }
    }
}
